﻿using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;

namespace MVC高级教程.Controllers
{
    /// <summary>
    /// 讲解.net core 的Identity，登录验证
    /// Identity是.net core帮助我们集成了登录的过程
    /// </summary>
    public class IdentityController : Controller
    {
        private readonly IHttpContextAccessor _httpcontext;

        public IdentityController(IHttpContextAccessor httpContextAccessor)
        {
            _httpcontext = httpContextAccessor;
        }

        public IActionResult Index()
        {
            //在讲HTTPContext的时候，上下文对象HTTPContext中就有一个User属性
            var identity=  _httpcontext.HttpContext.User.Identity;//身份属性是只读的

           

            return View();
        }


        /**
            Identity重点类
                ①、Usermanager<IdentityUser>
                               用于操作用户管理的服务类
                ②、SigninManager<IdentityUser>
                               用户身份校验的类
         **/
    }
}
